package com.cy.session;

import java.io.Serializable;
import java.util.List;

import com.cy.entity.BackPurview;
import com.cy.entity.BackUserType;
import com.cy.util.StringUtils;

public class SessionUser implements Serializable {

	private static final long serialVersionUID = -4746561968981665461L;
	
	public static final String	SESSION_BACKUSER_KEY	=	"sessionBackUser";
	
	private Long id;
	private String loginName;									//帐号
    private String password;									//密码
    private String nickname;								    //用户昵称
    private String backuserNo;								    //用户编号
    private List<BackPurview> purviews;							//用户权限
    private BackUserType backUserType;
    
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getLoginName() {
		return loginName;
	}
	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public String getBackuserNo() {
		return backuserNo;
	}
	public void setBackuserNo(String backuserNo) {
		this.backuserNo = backuserNo;
	}
	public List<BackPurview> getPurviews() {
		return purviews;
	}
	public void setPurviews(List<BackPurview> purviews) {
		this.purviews = purviews;
	}
	public BackUserType getBackUserType() {
		return backUserType;
	}
	public void setBackUserType(BackUserType backUserType) {
		this.backUserType = backUserType;
	}
	
	public boolean checkPurview(String actionName){
		if (purviews==null) return false;
		for (BackPurview purview:purviews){
			if (StringUtils.isNotEmpty(purview.getActionName()) && purview.getActionName().toLowerCase().equals(actionName)){
				return true;
			}
			
		}
		return false;
	}
	

    
    
}
